<?php 
    header("Content-type: text/html; charset=utf-8");
    require_once('dbconnect.inc.php');
    require_once('auth.inc.php');

    $auth = new auth();

    $auth->setDefRedir($_SERVER['PHP_SELF']);

    $user = $auth->isauth($dbh,$_COOKIE, true);

    if (!$user || ($user['role'] != $auth->auth_role_adm))
    {
        header($auth->getAuthRedir());
        $cookie = $auth->getCookie();
        setcookie($cookie['name'], $cookie['value']);
        exit();
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

<head>
    <title>Управление пользователями.</title>
    <?php
        require_once('headers.inc.php');
    ?>
    <script src="users.js" type="text/javascript"></script>
</head>
<body>
<?php // menu bar
    require_once('menu.inc.php');

    print menu($menu_items, 'users.php');
?>

<div id="user-form" title="Новый пользователь">
    <form id="user-form1" class="FormGrid">

        <input type="hidden" name="oper" value=""/>
        <input type="hidden" name="id" value=""/>

        <table id = "user-form-table" cellspacing=10>

         <tr>
          <td id="label">
            <label for="name">Имя пользователя</label>
          </td>
          <td id="value">  
            <input type="text" name="name" value="" class="FormElement ui-widget-content ui-corner-all" />
          </td>
         </tr>

         <tr>
          <td id="label">
            <label for="name">Логин</label>
          </td>
          <td id="value">  
            <input type="text" name="login" value="" class="FormElement ui-widget-content ui-corner-all" />
          </td>
         </tr>

         <tr>
          <td id="label">
            <label for="name">Пароль</label>
          </td>
          <td id="value">  
            <input type="password" name="password1" value="" class="FormElement ui-widget-content ui-corner-all" />
          </td>
         </tr>

         <tr>
          <td id="label">
            <label for="name">Повтор пароля</label>
          </td>
          <td id="value">  
            <input type="password" name="password2" value="" class="FormElement ui-widget-content ui-corner-all" />
          </td>
         </tr>

         <tr>
          <td colspan=2>
            <fieldset class="FormElement ui-widget-content ui-corner-all">
            <legend>Роль пользователя</legend>
            <table id="user-form-role" width="100%">
               <tr>
                <td width="50%">
                    <label><input id='user' type="radio" name="role" value="0" />Наблюдатель</label>
                </td>
                <td width="50%">
                    <label><input type="radio" name="role" value="2" />Инженер</label>
                </td>
                
               </tr>
               <tr>
                <td width="50%">
                    <label><input type="radio" name="role" value="1" />Диспетчер</label>
                </td>
                <td width="50%">
                    <label><input type="radio" name="role" value="3" />Администратор</label>
                </td>
                </tr>
            </table>
            </fieldset>
          </td>
         </tr>
        </table>
    </form>
</div>


<div id="right-info" >
    <button id="add-button">Добавить</button>
    <button id="edit-button">Редактировать</button>
    <button id="remove-button">Удалить</button>
</div>

<div id="content" style="bottom:0">
<table id="list"></table> 
</div>


</body>
</html>
